import { AdviseDeApi } from "@/api/advise";
import { baseURL } from "@/api/request";
import { useRequest } from "ahooks";
import { Avatar, Button,Image} from "antd";
import { useEffect, useState } from "react";
import { useParams } from "umi"
import QRCode from 'qrcode.react'
const AdviseDetail = ()=>{
    const params:{id:string} = useParams()
    console.log(params);
    const [data,setData] = useState<addAdviseTypes>()
    const getData = useRequest(AdviseDeApi,{
        manual:true,
        onSuccess:(res)=>{
            console.log(res);
            setData(res.result)
        }
    })
    useEffect(()=>{
        getData.run(params.id)
    },[])
    return (
        <div>
            <h3>意见详情  <Button onClick={()=>history.go(-1)}> 返回</Button> </h3>
            {
                data &&
                 <div>
                    <h2 className="title"> {data.title }</h2>
                    <h2 className="title"> {data.time  }</h2>
                    <h2 className="title"> {data.type  }</h2>
                    <div dangerouslySetInnerHTML={{__html:data.content}}></div>
                    <h2 className="title"> {data.author.username  }</h2>
                    <h2 className="title"> {data.author.phone   }</h2>

                    <Avatar src={data.author?.avatar ? data.author?.avatar.replace(/public/,baseURL) : ''}></Avatar>
                    <div>
                        <Image src={data?.desc?.replace(/public/,baseURL)}></Image>
                    </div>
                    <div>
                        <span>投诉二维码</span>
                        <div>
                            <QRCode
                                value={"http://101.37.23.156/wh2217/admins/#/./pro/advise/detail/"+params.id}  //value参数为字符串类型
                                size={200} //二维码的宽高尺寸
                            >
                            </QRCode>
                        </div>
                    </div>
                 </div>
            }
        </div>
    )
}

export default AdviseDetail